package demo.practice.binary_search;

public class P162 {

    //1,2,1,3,5,6,4
    //
    public int findPeakElement(int[] nums) {


        int min=0;
        int max=nums.length-1;

        while (min<max){
            int mid= min+(max-min)/2;

            if(mid+1<nums.length &&  nums[mid]>nums[mid+1]){
                //峰值在前面
                max=mid;
            }else{
                //峰值在后面，且当前值不是峰值
                min=mid+1;
            }
        }
        return min;
    }


}
